package com.dwxt.community.controller.supervisor;

import com.dwxt.common.base.*;
import com.dwxt.community.aiequipment.sellmachine.entity.*;
import com.dwxt.community.aiequipment.sellmachine.entity.dto.*;
import com.dwxt.community.aiequipment.sellmachine.service.*;
import org.apache.commons.lang3.*;
import org.springframework.beans.factory.annotation.*;
import org.springframework.validation.annotation.*;
import org.springframework.web.bind.annotation.*;

import javax.validation.*;
import java.util.*;

/**
 * @program: intelligentcity
 * @description:
 * @author
 * @create: 2020/05/18
 */
@RestController
@RequestMapping("/cms/sellMachine")
public class SellMachineController {

    @Autowired
    private SellMachineService sellMachineService;

    /**
     * 获取售货机商品
     * @param no
     * @return
     */
    @RequestMapping("/getGoodsBySellMachineId")
    public BaseResult getGoodsBySellMachineId(String no){
        if (StringUtils.isBlank(no)){
            return BaseResult.build(StatusCode.SELL_MACHINE_NOT_EXIST);
        }
        return sellMachineService.getGoodsBySellMachineId(no);
    }

    /**
     * 补货
     * @return
     */
    @RequestMapping("/replenishment")
    public BaseResult replenishment(@RequestBody @Validated ArrayList<SellMachineAisle> sellMachineAisles){
        if (ObjectUtils.isEmpty(sellMachineAisles)){
            return BaseResult.build(StatusCode.PARAMETER_WRONG);
        }
        return sellMachineService.replenishment(sellMachineAisles);
    }


}
